<script setup lang="ts">
class MyHashSet {
  num: number[] = []
  hashFunc: number
  constructor(math?: number) {
    this.hashFunc = math ?? 100
  }

  add(key: number): void {
    let nowPosition = key % this.hashFunc
    if(this.num[nowPosition]==null||this.num[nowPosition]==-1){
      this.num[nowPosition]=key
      return
    }
    if(this.num[nowPosition] !== key) {
      for(let i =0;i<this.num.length;i++){
        if(this.num[nowPosition+i]==null||this.num[nowPosition+i]==-1){
          this.num[nowPosition + i ] = key
        }
      }
    }
  }

  remove(key: number): void {
    this.num[key % this.hashFunc] = -1
  }

  contains(key: number): boolean {
    let nowPosition = key % this.hashFunc
    if(this.num[nowPosition] == key){
      return true
    }
    this.num.some((item,index)=>{
      if(index>nowPosition){
        return item==key
      }
    })
    return false
  }
}

/**
 * Your MyHashSet object will be instantiated and called as such:
 * var obj = new MyHashSet()
 * obj.add(key)
 * obj.remove(key)
 * var param_3 = obj.contains(key)
 */
</script>

<template>
  <p>hashMap</p>
</template>

<style scoped></style>
